<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
   var a = prompt("请输入一个网址","www.baidu.com");

        var reg = /^w{3}\.{1}[a-z]+\.{1}[a-z]*$/;
        var str = "www.lagou.com";
        console .log(a.replace(reg,str));
  </script>
</body>
</html>